package cn.z2huo.knowledge.concurrency.atomic;

import java.util.concurrent.atomic.LongAdder;

/**
 * <p>
 *
 * @author z2huo
 */
class LongAdderTest {

    private LongAdder longAdder = new LongAdder();

    public void incr() {
        System.out.println(longAdder.longValue());
        longAdder.increment();
        System.out.println(longAdder.longValue());
        longAdder.increment();
        System.out.println(longAdder.longValue());
        longAdder.increment();
        System.out.println(longAdder.longValue());

        System.out.println(longAdder.sum());
    }

    public void add(long i) {
        longAdder.add(i);
    }
    
    public static void main(String[] args) {
        LongAdderTest longAdderTest = new LongAdderTest();
        longAdderTest.incr();
        System.out.println("====");
        longAdderTest.add(100);
        System.out.println(longAdderTest.longAdder.longValue());
    }

}
